<template>
  <div>
    <div class="gva-form-box">
      <el-form :model="formData" ref="elFormRef" label-position="right" :rules="rule" label-width="80px">
      {{- range .}}
        <el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}">
        {{- if eq .FieldType "bool" }}
          <el-switch v-model="formData.{{.FieldJson}}" active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" clearable ></el-switch>
        {{- end }}
        {{- if eq .FieldType "string" }}
          <el-input v-model="formData.{{.FieldJson}}" placeholder="请输入" />
        {{- end }}
        {{- if eq .FieldType "richtext" }}
          <RichEdit v-model="formData.{{.FieldJson}}"/>
        {{- end }}
        {{- if eq .FieldType "int" }}
        {{- if .DictType }}
          <el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" :clearable="{{.Clearable}}">
            <el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
          </el-select>
        {{- else }}
          <el-input v-model.number="formData.{{ .FieldJson }}" placeholder="请输入2" />
        {{- end }}
        {{- end }}
        {{- if eq .FieldType "time.Time" }}
          <el-date-picker v-model="formData.{{ .FieldJson }}" type="date" placeholder="选择日期"></el-date-picker>
        {{- end }}
        {{- if eq .FieldType "float64" }}
          <el-input-number v-model="formData.{{ .FieldJson }}" :precision="2"></el-input-number>
        {{- end }}
        {{- if eq .FieldType "enum" }}
          <el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" style="width:100%">
            <el-option v-for="item in [{{ .DataTypeLong }}]" :key="item" :label="item" :value="item" />
          </el-select>
        {{- end }}
        {{- if eq .FieldType "picture" }}
          <SelectImage v-model="formData.{{ .FieldJson }}" file-type="image"/>
        {{- end }}
        {{- if eq .FieldType "video" }}
          <SelectImage v-model="formData.{{ .FieldJson }}" file-type="video"/>
        {{- end }}
        {{- if eq .FieldType "pictures" }}
          <SelectImage v-model="formData.{{ .FieldJson }}" multiple file-type="image"/>
        {{- end }}
        {{- if eq .FieldType "file" }}
          <SelectFile v-model="formData.{{ .FieldJson }}" />
        {{- end }}
        </el-form-item>
      {{- end }}
        <el-form-item>
          <el-button type="primary" @click="save">保存</el-button>
          <el-button type="primary" @click="back">返回</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
